package com._520it.crm.service.impl;

import com._520it.crm.domain.AuditInfo;
import com._520it.crm.mapper.AuditInfoMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.AuditInfoQueryObject;
import com._520it.crm.service.IAuditInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
@Service
public class AuditInfoServiceImpl implements IAuditInfoService {
    @Autowired
    private AuditInfoMapper auditInfoMapper;


    @Override
    public int deleteByPrimaryKey(Long id) {
        return auditInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(AuditInfo record) {
        return auditInfoMapper.insert(record);
    }

    @Override
    public AuditInfo selectByPrimaryKey(Long id) {
        return auditInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<AuditInfo> selectAll() {
        return auditInfoMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(AuditInfo record) {
        return auditInfoMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult query(AuditInfoQueryObject qo) {
        Integer count = auditInfoMapper.queryForCount(qo);
        if (count == 0){
            return new PageResult(0, Collections.EMPTY_LIST);
        }
        List<AuditInfo> rows = auditInfoMapper.queryForList(qo);
        return new PageResult(count,rows);
    }
}
